<html>
	<head>
		<meta charset="utf-8">
		<title>条码打印</title>
	</head>
	<body>
		{if ( $error == 1) }
			{$message}
		{else/}
			{foreach $data.delivery_goods as $kg => $dg }
			<div  id="div{$kg}">
				<TABLE border=0 cellSpacing=0 cellPadding=0 width="100%">
				  	<TBODY>
					<TR>
						<TD  colspan="2" ><font >
							物料编码：<SPAN id=rpt_Pro_Order_List_ctl00_lbl_eShop_Name></SPAN></font>{$dg.material_number}
					  	</TD>
					</TR>
					<TR>
						<TD width="50%"><font >
							物料名称：<SPAN id=rpt_Pro_Order_List_ctl00_lbl_eShop_Name></SPAN></font>{$dg.material_name}
					  	</TD>
					    <TD >
					    	<font >采购订单：<SPAN >{$data.order_purchase['fill_no']}</SPAN></font>
					    </TD>
					</TR>
					<TR>
						<TD width="50%"><font >
							规格型号：<SPAN id=rpt_Pro_Order_List_ctl00_lbl_eShop_Name></SPAN></font>{$dg.model}
					  	</TD>
					    <TD >
					    	<font >装箱规格：<SPAN >{$dg.spec}</SPAN></font>
					    </TD>
					</TR>
					<TR>
						<TD colspan="9" width="90%"><b>&nbsp;</b></TD>
						<TD ><a href="javascript:generateBarcode({$dg|json_encode},{$data.order_purchase|json_encode});">打印</a></TD>
					</TR>
					</TBODY>
				</TABLE>
			</div>
			{/foreach}
<!-- 			<div>
			<TABLE border=0 cellSpacing=0 cellPadding=0 width="100%">
				<TBODY>
					<TR>
						<TD colspan="9" width="90%"><b>&nbsp;</b></TD>
						<TD ><a href="javascript:generateBarcode();">打印</a></TD>
					</TR>
				</TBODY>
			</TABLE>
			</div> -->
		{/if}
		<script src="{$host}/static/js/LodopFuncs.js" type="text/javascript" charset="utf-8" > </script>
		<script src="{$host}/static/js/jquery-2.0.2.min.js" type="text/javascript" charset="utf-8" > </script>
		<script type="text/javascript" charset="utf-8" >

			function generateBarcode(dg,order) {
				console.log({goods:dg,order:order});
				printMytable(dg, order);
				return;
				var url = '{$host}/api/v1/delivery/generateBarcode?id={$data.id}'
					,param = {
						goods:dg
					}
				$.ajax({
					type: "post",
					url: url,
					data: param,
					dataType: 'json',
					beforeSend: function(request) {
                        request.setRequestHeader("Authorization", "{$authorization}");
                    },
					success: function(res) {
						var delivery_goods = res.content.delivery_goods
							,order = res.content.order_purchase
							,goods_length = res.content.delivery_goods.length

						console.log(res);
						for (var i = delivery_goods.length - 1; i >= 0; i--) {
							printMytable(delivery_goods[i], order);
							
						}
					},
					error:function(err){
						console.info('error', err)
					}
				})
			}
			function printMytable(goods, order){
				var LODOP=getLodop();  

				LODOP.ADD_PRINT_TEXT(50,"2.4%",177,56, '物料编码：');
				LODOP.SET_PRINT_STYLEA(0,"FontName","Arial");
				LODOP.SET_PRINT_STYLEA(0,"FontSize",8);
				LODOP.SET_PRINT_STYLEA(0,"LetterSpacing",1);
				LODOP.ADD_PRINT_TEXT(45,"17%",350,56, goods.material_number);
				LODOP.SET_PRINT_STYLEA(0,"FontName","Arial");
				LODOP.SET_PRINT_STYLEA(0,"FontSize",12);
				LODOP.SET_PRINT_STYLEA(0,"LetterSpacing",1);

				LODOP.ADD_PRINT_TEXT(68,"2.4%",177,56, '物料名称：');
				LODOP.SET_PRINT_STYLEA(0,"FontName","Arial");
				LODOP.SET_PRINT_STYLEA(0,"FontSize",8);
				LODOP.SET_PRINT_STYLEA(0,"LetterSpacing",1);
				LODOP.ADD_PRINT_TEXT(68,"17%",177,56, goods.material_name);
				LODOP.SET_PRINT_STYLEA(0,"FontName","Arial");
				LODOP.SET_PRINT_STYLEA(0,"FontSize",8);
				LODOP.SET_PRINT_STYLEA(0,"LetterSpacing",1);
				
				LODOP.ADD_PRINT_TEXT(68,"54%",177,56, '采购订单：');
				LODOP.SET_PRINT_STYLEA(0,"FontName","Arial");
				LODOP.SET_PRINT_STYLEA(0,"FontSize",8);
				LODOP.SET_PRINT_STYLEA(0,"LetterSpacing",1);
				LODOP.ADD_PRINT_TEXT(68,"69%",177,56, order.fill_no);
				LODOP.SET_PRINT_STYLEA(0,"FontName","Arial");
				LODOP.SET_PRINT_STYLEA(0,"FontSize",7.5);
				LODOP.SET_PRINT_STYLEA(0,"LetterSpacing",1);
				
				LODOP.ADD_PRINT_TEXT(88,"2.4%",177,56, '规格型号：');
				LODOP.SET_PRINT_STYLEA(0,"FontName","Arial");
				LODOP.SET_PRINT_STYLEA(0,"FontSize",8);
				LODOP.SET_PRINT_STYLEA(0,"LetterSpacing",1);
				LODOP.ADD_PRINT_TEXT(88,"17%",177,56, goods.model);
				LODOP.SET_PRINT_STYLEA(0,"FontName","Arial");
				LODOP.SET_PRINT_STYLEA(0,"FontSize",8);
				LODOP.SET_PRINT_STYLEA(0,"LetterSpacing",1);

				LODOP.ADD_PRINT_TEXT(88,"54%",177,56, '装箱规格：');
				LODOP.SET_PRINT_STYLEA(0,"FontName","Arial");
				LODOP.SET_PRINT_STYLEA(0,"FontSize",8);
				LODOP.SET_PRINT_STYLEA(0,"LetterSpacing",1);
				LODOP.ADD_PRINT_TEXT(88,"69%",177,56, goods.spec);
				LODOP.SET_PRINT_STYLEA(0,"FontName","Arial");
				LODOP.SET_PRINT_STYLEA(0,"FontSize",8);
				LODOP.SET_PRINT_STYLEA(0,"LetterSpacing",0.5);

				LODOP.ADD_PRINT_BARCODE(118,34,307,35,"EAN128B", goods.barcode);
				LODOP.SET_PRINT_STYLEA(0,"AlignJustify",2);
				LODOP.SET_PRINT_STYLEA(0,"FontSize",8);
				LODOP.SET_PRINT_COPIES(goods.box);
				LODOP.SET_PRINT_MODE("RESELECT_COPIES",1);
				LODOP.PREVIEW();
				// LODOP.PRINT();
			};	
		</script>
	</body>
</html>
